package seqlist.stack_queue.queue.impl;

import seqlist.stack_queue.queue.MyQueue;

import java.util.Queue;

/**
 * @author yuisama
 * @date 2023/03/31 19:03
 **/
public class PriorityQueueTest {
    public static void main(String[] args) {
        MyQueue<Integer> queue = new PriorityQueue();
        queue.offer(1);
        queue.offer(5);
        queue.offer(3);
        queue.offer(2);
        queue.offer(9);
        queue.offer(7);
        // 此时值越大，优先级越高~
        System.out.println(queue.poll());
        // JDK的优先级队列
        // 默认最小堆的实现
        Queue<Integer> queue1 = new java.util.PriorityQueue<>();
        queue1.offer(2);
        queue1.offer(1);
        queue1.offer(5);
        queue1.offer(3);
        queue1.offer(9);
        queue1.offer(7);
        // 此时的优先级，值越小，优先级越高
        System.out.println(queue1.poll());
    }
}